/**
 * Created by Skye on 2018/3/22.
 */
import { combineReducers } from 'redux'
import { SET_USER_INFO, SET_ACCOUNT_LIST, COLLAPSED, SET_MENU_LIST, initialState } from '../actions'


function setUserInfo(state = initialState.userInfo, action) {
  switch (action.type) {
    case SET_USER_INFO:
      return Object.assign({}, state, action.userInfo)
    default:
      return state
  }
}

function setAccountList(state = initialState.accountList, action) {
  switch (action.type) {
    case SET_ACCOUNT_LIST:
      return action.accountList
    default:
      return state
  }
}

function setCollapsed(state = initialState.collapsed, action) {
  switch (action.type) {
    case COLLAPSED:
      return action.collapsed
    default:
      return state
  }
}

function setMenuList( state = initialState.menuList, action ) {
  switch (action.type) {
    case SET_MENU_LIST:
      return action.menuList
    default:
      return state
  }
}

const allReducers = combineReducers({
  userInfo: setUserInfo,
  accountList: setAccountList,
  collapsed: setCollapsed,
  menuList: setMenuList
})

export default allReducers;